var React = require('react');

// 纯粹的按钮(view层)
var MyButton = React.createClass({
	render:function(){
		var items = this.props.items;
		var vm = this;
		
		var itemHtml = items.map(function(listItem,i){
			return (
				<li key={i}>{listItem} <button data-index={i} onClick={vm.props.onRemoveItemHandle}>X</button></li>
			)
		})

		return (
			<div>
				<div><input type="text" onKeyUp={this.props.onEnterHandle}/></div>
				<ul>{itemHtml}</ul>
				<button onClick={this.props.onClick}>New Item</button>
			</div>
		)
	}
})

module.exports = MyButton;